//
//  LPFVisitorTableVC.swift
//  WeiBo
//
//  Created by mac on 16/4/17.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class LPFVisitorTableVC: UITableViewController {

    // 判断用户是否登录标识
    var isLogin: Bool = LPFUserAccountTools.sharedTools.isLogin
    //访客视图
    var visitorView: LPFVisitorView?
    
    override func loadView() {
        //判断是否登录
        isLogin ? super.loadView() : setupVisitorView()
    }
    
    override func viewDidLoad() {
        
    }
    
    // MARK: - 设置视图
    private func setupVisitorView(){
        setupNav()
        visitorView = LPFVisitorView()
        visitorView?.visitorClosure = {
            self.login()
        }
        view = visitorView
    }
    
    // MARK: - 导航栏设置
    private func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
    }
    
    // MARK: - 登录按钮监听事件
    @objc private func login(){
        let oauthVC = LPFOAuthVC()
        presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
    }
    
    
}
